home *** CD-ROM | disk | FTP | other *** search
- /*
- ** GadTools layout toolkit
- **
- ** Copyright © 1993-1996 by Olaf `Olsen' Barthel
- ** Freely distributable.
- **
- ** :ts=4
- */
-
- #ifndef _GTLAYOUT_GLOBAL_H
- #include "gtlayout_global.h"
- #endif
-
- /****** gtlayout.library/LT_Init ******************************************
- *
- * NAME
- * LT_Init -- Initialize user interface code.
- *
- * SYNOPSIS
- * LT_Init();
- *
- * VOID LT_Init(VOID);
- *
- * FUNCTION
- * You need to initialize the user interface code only once,
- * so it can set up its internals, open libraries, etc.
- * The code has to be initialized before any user interface
- * creation can take place.
- *
- * NOTES
- * This function is not present in the shared library, only
- * in the link library. You need not and cannot invoke it in
- * the shared library.
- *
- * SEE ALSO
- * gtlayout.library/LT_Exit
- *
- ******************************************************************************
- *
- */
-
- BOOL LIBENT
- LT_Init()
- {
- #ifndef LINK_LIB
- SysBase = *(struct ExecBase **)4;
- #endif // LINK_LIB
-
- if(SysBase->LibNode.lib_Version < 37)
- return(FALSE);
- else
- {
- STATIC struct { STRPTR Name; APTR *Library; } InitTable[] =
- {
- "intuition.library", (APTR *)&IntuitionBase,
- "graphics.library", (APTR *)&GfxBase,
- "utility.library", (APTR *)&UtilityBase,
- "gadtools.library", (APTR *)&GadToolsBase,
- "keymap.library", (APTR *)&KeymapBase,
- "locale.library", (APTR *)&LocaleBase
- };
-
- LONG i;
-
- V39 = (SysBase->LibNode.lib_Version >= 39);
- V40 = (SysBase->LibNode.lib_Version >= 40);
-
- for(i = 0 ; i < NUMELEMENTS(InitTable) ; i++)
- *InitTable[i].Library = OpenLibrary(InitTable[i].Name,37);
-
- if(IntuitionBase && GfxBase && UtilityBase && GadToolsBase && KeymapBase)
- {
- if(LocaleBase)
- LTP_Locale = OpenLocale(NULL);
-
- if(LTP_ImageClass = MakeClass(NULL,IMAGECLASS,NULL,sizeof(ImageInfo),0))
- {
- LTP_ImageClass->cl_Dispatcher.h_Entry = (HOOKFUNC)LTP_ImageDispatch;
-
- #ifdef DO_LEVEL_KIND
- if(LTP_LevelClass = MakeClass(NULL,IMAGECLASS,NULL,sizeof(LevelImageInfo),0))
- {
- LTP_LevelClass->cl_Dispatcher.h_Entry = (HOOKFUNC)LTP_LevelClassDispatcher;
- #else
- {
- #endif /* DO_LEVEL_KIND */
-
- #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
- if(LTP_PopupClass = MakeClass(NULL,GADGETCLASS,NULL,sizeof(PopInfo),0))
- {
- LTP_PopupClass->cl_Dispatcher.h_Entry = (HOOKFUNC)LTP_PopupClassDispatcher;
- #else
- {
- #endif // DO_POPUP_KIND
-
- #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
- if(LTP_TabClass = MakeClass(NULL,GADGETCLASS,NULL,sizeof(TabInfo),0))
- {
- LTP_TabClass->cl_Dispatcher.h_Entry = (HOOKFUNC)LTP_TabClassDispatcher;
- #else
- {
- #endif // DO_TAB_KIND
-
- #ifdef DO_PICKSHORTCUTS
- InitSemaphore(<P_KeySemaphore);
-
- if(LTP_Keys[0] = (UBYTE *)AllocMem(512,MEMF_ANY|MEMF_CLEAR))
- {
- #else
- {
- #endif /* DO_PICKSHORTCUTS */
- InitSemaphore(<P_LockSemaphore);
-
- NewList((struct List *)<P_LockList);
- NewList((struct List *)<P_EmptyList);
-
- return(TRUE);
- }
- }
- }
- }
- }
- }
-
- LT_Exit();
-
- return(FALSE);
- }
- }
-
-
- /*****************************************************************************/
-
-
- /****** gtlayout.library/LT_Exit ******************************************
- *
- * NAME
- * LT_Exit -- Clean up user interface allocations
- *
- * SYNOPSIS
- * LT_Exit();
- *
- * VOID LT_Exit(VOID);
- *
- * FUNCTION
- * When you are finished with user interface creation and
- * do not not need the code any more you should call this
- * routine. It will free all the memory allocated by
- * LT_Init(), close libraries, etc.
- *
- * INPUTS
- * none
- *
- * RESULT
- * none
- *
- * NOTES
- * This function is not present in the shared library, only
- * in the link library. You need not and cannot invoke it in
- * the shared library.
- *
- * SEE ALSO
- * gtlayout.library/LT_Init
- *
- ******************************************************************************
- *
- */
-
- VOID LIBENT
- LT_Exit()
- {
- if(SysBase && SysBase->LibNode.lib_Version >= 37)
- {
- #ifdef DO_PICKSHORTCUTS
- FreeMem(LTP_Keys[0],512);
- LTP_Keys[0] = LTP_Keys[1] = NULL;
- #endif
-
- #ifdef DO_LEVEL_KIND
- if(LTP_LevelClass)
- {
- FreeClass(LTP_LevelClass);
- LTP_LevelClass = NULL;
- }
- #endif /* DO_LEVEL_KIND */
-
- #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
- if(LTP_PopupClass)
- {
- FreeClass(LTP_PopupClass);
- LTP_PopupClass = NULL;
- }
- #endif // DO_POPUP_KIND
-
- #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
- if(LTP_TabClass)
- {
- FreeClass(LTP_TabClass);
- LTP_TabClass = NULL;
- }
- #endif // DO_TAB_KIND
-
- if(LTP_ImageClass)
- {
- FreeClass(LTP_ImageClass);
- LTP_ImageClass = NULL;
- }
-
- if(LTP_Locale)
- {
- CloseLocale(LTP_Locale);
- LTP_Locale = NULL;
- }
-
- CloseLibrary(LocaleBase);
- LocaleBase = NULL;
-
- CloseLibrary(KeymapBase);
- KeymapBase = NULL;
-
- CloseLibrary(GadToolsBase);
- GadToolsBase = NULL;
-
- CloseLibrary(UtilityBase);
- UtilityBase = NULL;
-
- CloseLibrary(GfxBase);
- GfxBase = NULL;
-
- CloseLibrary(IntuitionBase);
- IntuitionBase = NULL;
- }
- }
-